require "Common/define"
require "Logic/Config"
require "Net/send_Msg"
require "Net/friendHandler"
require "Net/picFrameHandler"
require "Common/functions"

UIHeadInfo = {};
HelperFunc.SetUIEnv(UIHeadInfo)
local this = UIHeadInfo;

this.gameObject = nil;
this.bt_SetBtn = nil
this.btnCopy = nil;
this.exp = nil;
this.ctrlMainSex = nil
this.lable_name = nil;
this.lable_Lv = nil;
this.lable_Id = nil;
this.power = nil;
this.barName = nil;
this.ChoseHeadDesc = nil;
this.headName = nil;
this.bt_close = nil;
this.btnChangeFormation = nil
this.ChoseFormationPanel = nil;
this.btnCloseForm = nil;
this.dynamicListForm = nil;
this.drawWrapper = nil;
this.titleBtn = nil;
this.ctrlTabController = nil;

this.changeSex = nil;
this.sexType = EnumConst.SexType.Boy
this.btnChangeName = nil;
this.changeNameNeedMoney = nil;
this.inputName = nil;
this.closeChangeName = nil;

this.table_banch = nil;
this.mainMap = nil;
this.mysticalRoad = nil;
this.AreanaRankMax = nil;
this.AreanaRankNow = nil;
this.HeroGot = nil;
this.HeroGotMax = nil
this.HeroGotRate = nil;
this.heroFormObj = {}
this.headFormationObj = {}
this.headPic = nil;
this.framePic = nil;
this.CardContent = nil;
this.btnSendForm = nil;
this.btnChoseSideMan = nil;
this.btnChoseHeadIcon = nil;
this.ChoseHeadIconPanel = nil;
this.DrawingParent = nil;
this.role_liHui = nil;
this.LiHuiObj = nil;
this.PicIDNotSave = nil;
this.ChangeNamePanel = nil;
this.btnChangeNameShow = nil;
this.Severname = nil;
this.SevernameId = nil
this.showTitles = nil;

this.headIcon = nil;
this.headFrame = nil;
this.dynamicListUp = nil;
this.dynamicListDown = nil;
this.btnSendHead = nil;
this.btnCloseHeadChose = nil;
this.listBeGetTab = nil;
this.listUnGetTab = nil;

this.headController = nil;
this.teamController = nil;
this.nameChangeOpenController = nil;
this.headOpenController = nil;
this.headbtn = nil;
this.framebtn = nil;
this.frameGet = nil;
this.frameUnGet = nil;
this.config = nil;
this.drawWrappers = {};
this.particles = {};
this.topid = nil;
this.preid = nil;
this.mapname=nil;
this.showHeroObj = {};
this.setController = nil;
this.currentHeroId = 0
this.btn_vip = nil
this.btn_vipRed= nil
this.blendTimer = nil
this.delayObjTimer = nil
UIHeadInfo.sendForm = {}
UIHeadInfo.timerCountDown = {}

local attr_list = {}

function UIHeadInfo.Init()
    config = G.dataTable["t_item"];
    local name, packageName = getUIName(PanelNames.UIHeadInfo);
    panelMgr:ShowUI(name, packageName, this.OnCreate, Config.useLocalUI);
end

--定义控件
function UIHeadInfo.OnCreate(obj)
    gameObject = obj;
    nameChangeOpenController = obj:GetController("changePage");
    headOpenController = obj:GetController("headPage");
    teamController = obj:GetController("teamPage");
    setController = obj:GetController("set");
    ctrlMainSex = obj:GetController("mainsex")

    mapname=obj:GetChild("MapName");
    InfoBtn = obj:GetChild("InfoBtn")
    Severname = obj:GetChild("Severname");
    SevernameId = obj:GetChild("SevernameId");
    bt_close = obj:GetChild("Backbtn");
    bt_SetBtn = obj:GetChild("SettingBtn");
    bt_SetBtn:GetChild("UIRedDots"):GetController("c1").selectedIndex = logicMgr.SDKManager.GetAccountCenterCount() > 0 and 2 or 0
    btn_Copy = obj:GetChild("Btn_Copy")
    exp = obj:GetChild("adventureSlider");
    this.numLevelNow = obj:GetChild("numLevelNow");
    this.numLevelNeed = obj:GetChild("numLevelNeed");
    lable_Lv = obj:GetChild("LV");
    lable_Id = obj:GetChild("IDTips");
    lable_name = obj:GetChild("NameLb");
    guildNameText = obj:GetChild("Severname3");
    guildPostText = obj:GetChild("Severname4");
    titleBtn = obj:GetChild("BadgeEdit")
    mainMap = obj:GetChild("MainMap");
    mysticalRoad = obj:GetChild("MainMapLevel");
    AreanaRankMax = obj:GetChild("battleRankId");
    AreanaRankNow = obj:GetChild("battleRank");
    HeroGotMax = obj:GetChild("heroNumMax");
    HeroGot = obj:GetChild("heroNum");
    HeroGotRate = obj:GetChild("heroRate");
    power = obj:GetChild("textfightPower");
    btnChangeNameShow = obj:GetChild("changeNameBtn");
    btnChangeFormation = obj:GetChild("btnChangeFormation");
    DrawingParent = {}
    DrawingParent[1] = obj:GetChild("Charactormask");
    DrawingParent[2] = obj:GetChild("Charactormask2");
    btnChoseSideMan = obj:GetChild("btnSideMan");
    btnChoseSide2D  = obj:GetChild("btnSide2D");
    ChoseFormationPanel = obj:GetChild("teamChose");
    this.province = obj:GetChild("province");
    this.city = obj:GetChild("city");
    btnCopy = obj:GetChild("Btn_Copy");
    chooseClosebg = ChoseFormationPanel:GetChild("bg");
    btnCloseForm = ChoseFormationPanel:GetChild("black");
    dynamicListForm = ChoseFormationPanel:GetChild("list");
    CardContent = ChoseFormationPanel:GetChild("CardContent");
    btnSendForm = ChoseFormationPanel:GetChild("btnSendForm");
    ctrlTabController = ChoseFormationPanel:GetController("ctrlTab");
    btnChoseHeadIcon = obj:GetChild("HeadIcon");
    ChoseHeadIconPanel = obj:GetChild("headChose");
    headController = ChoseHeadIconPanel:GetController("c1")
    playerHead_attr = ChoseHeadIconPanel:GetController("attr")
    attr_list[1] = ChoseHeadIconPanel:GetChild("attr1")
    attr_list[2] = ChoseHeadIconPanel:GetChild("attr2")
    attr_list[3] = ChoseHeadIconPanel:GetChild("attr3")
    attr_list[4] = ChoseHeadIconPanel:GetChild("attr4")
    btnSendHead = ChoseHeadIconPanel:GetChild("start");
    headbtn = ChoseHeadIconPanel:GetChild("n24");
    framebtn = ChoseHeadIconPanel:GetChild("n25");
    dynamicListUp = ChoseHeadIconPanel:GetChild("listBeGet");
    headIcon = ChoseHeadIconPanel:GetChild("HeadIcon"):GetChild("head"):GetChild("HeadIcon");
    headFrame = ChoseHeadIconPanel:GetChild("HeadIcon"):GetChild("frame");
    barName = ChoseHeadIconPanel:GetChild("barName");
    ChoseHeadDesc = ChoseHeadIconPanel:GetChild("desc");
    headName = ChoseHeadIconPanel:GetChild("headName");
    btnCloseHeadChose = ChoseHeadIconPanel:GetChild("black");
    btnBgcloseChoose = ChoseHeadIconPanel:GetChild("bgClose");
    mapname.text=getLanguage("HelpTitle3")
    btn_vip = obj:GetChild("Btn_Vip")
    btn_vipRed = btn_vip:GetChild("UIRedDots")
    this.role_liHui = {}
    drawWrapper = {}
    heroFormObj = {}
    for i = 1, 5 do
        local tempobj = obj:GetChild("heroPo" .. i);
        table.insert(heroFormObj, tempobj)
    end
    for i = 1, 5 do
        table.insert(headFormationObj, ChoseFormationPanel:GetChild("formation" .. i));
    end
    showTitles = {};
    for i = 1, 5 do
        table.insert(showTitles, obj:GetChild("Badge" .. i));
    end
    this.reLogin = false;
    this.VIPLevel()
    this.addEvent();
    this.CloseFom();
    TitleHandler.SendTitleInfo();
    this.SetInfo();
    UIRedDots.addViewListen(PanelNames.UIHeadInfo, "UIHeadInfo" .. btnChoseHeadIcon .name, btnChoseHeadIcon, Config.RedDotsType.HeadFrame);
    UIRedDots.addViewListen(PanelNames.UIHeadInfo, "UIHeadInfo" .. bt_SetBtn.name, bt_SetBtn, Config.RedDotsType.uiSpeed);
    this.TitleRedListen();
    logicMgr.FuncOpenManager.addStatusCtr(PanelNames.UIHeadInfo, Config.FuncOpenType.Title, titleBtn.name, titleBtn);
    logicMgr.FuncOpenManager.addStatusCtr(PanelNames.UIHeadInfo, Config.FuncOpenType.Side2D, btnChoseSide2D.name, btnChoseSide2D);
end

function UIHeadInfo.OnEnable()
    this.LocalListenEvent();

end

function UIHeadInfo.GoVip()
    showUI(PanelNames.UIGiftVipDetail)
end

function UIHeadInfo.VIPLevel()
    btn_vip.title = logicMgr.VipManager.getVipLevel()
    btn_vipRed.visible = logicMgr.VipManager.GetVipIsHave()
end

function UIHeadInfo.OnDisable()
    headFormationObj = {}
    UIRedDots.removeViewEvent(PanelNames.UIHeadInfo);

    FuncOpenManager.removeStatusCtr(PanelNames.UIHeadInfo);

    this.LocalCloseEvent();
end

function UIHeadInfo.OnDestroy()
    --UIRedDots.removeViewEvent(PanelNames.UIHeadInfo);

    this.removeEvent();
    drawWrappers = {};
    for _, v in pairs(particles) do
        if v then
            destroyImmediate(v);
        else
            break ;
        end
    end
    if blendTimer then
        utimer.remove(blendTimer)
        blendTimer = nil
    end
    if delayObjTimer then
        utimer.remove(delayObjTimer)
        delayObjTimer = nil
    end
    particles = {}
    if role_liHui[1] then
        destroyImmediate(role_liHui[1])
        role_liHui[1] = nil
    end
    if role_liHui[2] then
        destroyImmediate(role_liHui[2])
        role_liHui[2] = nil
    end
    for k,v in pairs(UIHeadInfo.timerCountDown) do
        utimer.remove(v);
        v = nil;
    end
end

function UIHeadInfo.addEvent()
    btnChangeFormation.onClick:Add(function()
        this.ShowSelectFom(1);
    end);
    InfoBtn.onClick:Add(function()
        closeUI(PanelNames.UICommonSet);
    end)
    bt_close.onClick:Add(this.OnCloseClick);
    bt_SetBtn.onClick:Add(this.Setting);
    btn_Copy.onClick:Add(this.onCopyClick)
    --btnChangeName.onClick:Add(this.GoChangeName);
    btnChangeNameShow.onClick:Add(this.ShowChangeName);
    btnCloseForm.onClick:Add(this.CloseFom);
    chooseClosebg.onClick:Add(this.CloseFom);
    btnSendForm.onClick:Add(this.GochangeForm);
    titleBtn.onClick:Add(this.OpenTitle);
    btnChoseSideMan.onClick:Add(this.ShowSideManChose);
    btnChoseSide2D.onClick:Add(this.ShowSide2DChose);
    btnChoseHeadIcon.onClick:Add(this.AskHeadFrameInfo);
    btnSendHead.onClick:Add(this.GoChangeHead);
    btnCloseHeadChose.onClick:Add(this.CloseFom);
    btnBgcloseChoose.onClick:Add(this.CloseFom);
    --closeChangeName.onClick:Add(this.CloseFom);
    headbtn.onClick:Add(this.FrameBtnClick);
    framebtn.onClick:Add(this.FrameBtnClick);
    ctrlTabController.onChanged:Add(this.OnTabChanged)
    btn_vip.onClick:Add(this.GoVip)
end

function UIHeadInfo.removeEvent()
    bt_SetBtn.onClick:Clear();
    bt_close.onClick:Clear();
    titleBtn.onClick:Clear();
    btn_Copy.onClick:Clear();
    btnChangeNameShow.onClick:Clear();
    btnChangeFormation.onClick:Clear();
    btnCloseForm.onClick:Clear();
    chooseClosebg.onClick:Clear();
    btnSendForm.onClick:Clear();
    btnChoseSideMan.onClick:Clear();
    btnChoseSide2D.onClick:Clear();
    btnChoseHeadIcon.onClick:Clear();
    btnSendHead.onClick:Clear();
    btnCloseHeadChose.onClick:Clear();
    btnBgcloseChoose.onClick:Clear();

    --closeChangeName.onClick:Clear();
    headbtn.onClick:Clear();
    framebtn.onClick:Clear();
    ctrlTabController.onChanged:Clear()
    btn_vip.onClick:Clear()
end

function UIHeadInfo.LocalListenEvent()
    
    ListenEvent(Config.EventType.TitleInfo, this.setTitles); 
    ListenEvent(Config.EventType.FreashRoleShowDraw, this.ShowDrawing)
    ListenEvent(Config.EventType.FreashSettingDraw, this.ChangeSelectedHero)
    ListenEvent(Config.EventType.FreashRoleInfo, this.SetInfo)
    ListenEvent(Config.EventType.FreashRoleInfo, this.PowerInfo);

    ListenEvent(Config.EventType.FreashRoleShowDraw, this.ReSetHeadIcon)
    ListenEvent(Config.EventType.VIPInfoUpdate,this.VIPLevel)
    ListenEvent(Config.EventType.HeadFrameInfo, this.UpdateHeadFrameInfo)
    ListenEvent(Config.EventType.Account_center_unread_count, this.RefreshCenterRed)
end

function UIHeadInfo.LocalCloseEvent()
    
    CloseEvent(Config.EventType.FreashRoleShowDraw, this.ShowDrawing)
    CloseEvent(Config.EventType.FreashSettingDraw, this.ChangeSelectedHero)
    CloseEvent(Config.EventType.TitleInfo, this.setTitles)
    CloseEvent(Config.EventType.FreashRoleInfo, this.SetInfo)
    CloseEvent(Config.EventType.FreashRoleInfo, this.PowerInfo)

    CloseEvent(Config.EventType.FreashRoleShowDraw, this.ReSetHeadIcon)
    CloseEvent(Config.EventType.VIPInfoUpdate,this.VIPLevel)
    CloseEvent(Config.EventType.HeadFrameInfo, this.UpdateHeadFrameInfo)
    CloseEvent(Config.EventType.Account_center_unread_count, this.RefreshCenterRed)
end

function UIHeadInfo.ReSetHeadIcon()
    --local useSkinId = logicMgr.SkinManager.getHeroSkinId(logicMgr.HeroManager.GetRoleHeadID())
    --btnChoseHeadIcon:GetChild("head"):GetChild("HeadIcon").url = logicMgr.HeroManager.GetRoleIcon(useSkinId)

    local skinId = logicMgr.HeroManager.GetRoleInfo("pic")
    btnChoseHeadIcon:GetChild("head"):GetChild("HeadIcon").url = logicMgr.SkinManager.GetHeroIconBySkinId(skinId)
    SetHeadFEWithModelId(btnChoseHeadIcon,HeroManager.GetRoleHeadID())
    local frameId = this.framePic or logicMgr.HeroManager.GetRoleInfo("picFrame")
    btnChoseHeadIcon:GetChild("frame").url = "ui://ICONAtlas/" .. frameId;
    this.LoadParticle(frameId, btnChoseHeadIcon, true);
    headIcon.url = logicMgr.SkinManager.GetHeroIconBySkinId(skinId) -- logicMgr.HeroManager.GetRoleIcon(useSkinId);
end

function UIHeadInfo.PowerInfo(evt)
    if type(evt) == "number" then
        power.text = HelperFunc.FormatResourceNum(evt, true)
        return
    end
    if evt and evt.data then
        power.text = HelperFunc.FormatResourceNum(toNumber(tostring(evt.data.sumPower)), true)
    end
end
--- 显示/隐藏 名称修改界面
function UIHeadInfo.ShowChangeName()
    showUI(PanelNames.UIPlayerChangeName)
    --[[nameChangeOpenController.selectedIndex = 1
    changeSex.selectedIndex = logicMgr.HeroManager.GetRoleInfo("sex")

    ctrlModifyCount.selectedIndex = 0
    if logicMgr.HeroManager.GetRoleInfo("modifyCount") >= 1 then
        ctrlModifyCount.selectedIndex = 1
        inputName.text = logicMgr.HeroManager.GetRoleInfo("name");
    end]]
end

function UIHeadInfo.onCopyId()

end

function UIHeadInfo.HideChangeName()
    --nameChangeOpenController.selectedIndex = 0;
end

function UIHeadInfo.OpenTitle()
    if FuncOpenManager.isOpen(Config.FuncOpenType.Title, true, titleBtn) then
        logicMgr.TitleManager.setIsNewTitle(0);
        showUI(PanelNames.UIBadge);
    end
end

-- preHeroID预览id
function UIHeadInfo.setTitles(msg)
    if msg == nil then
        return ;
    end
    for i = 1, #showTitles do
        local id = msg.showList[i];
        local controller = showTitles[i]:GetController("state");
        if id ~= nil and id ~= 0 then
            controller.selectedIndex = 1;
            showTitles[i]:GetChild("icon").icon = "ui://ICONAtlas/" .. G.dataTable["t_medal"][tostring(id)].f_MedalPic;
        else
            controller.selectedIndex = 0;
        end
        local info = G.dataTable["t_medal"][tostring(id)]
        if info and info.f_GroupId == 6 then  --竞技场等级徽章加闪光特效
            local effect = showTitles[i]:GetChild("Effect_Dwsg");
            local level = info.f_LevelId;
            effect.animationName = "idle" .. level;
            effect.skinName = level;
            effect.loop = true;
        end
    end
end
function this.ChangeSelectedHero(preHeroID)
    this.ShowDrawing(preHeroID)
end

function UIHeadInfo.ShowDrawing(preHeroID)
    local index = 1
    local heroID = tostring(logicMgr.SkinManager.getHeroModelIdBySkinId(logicMgr.HeroManager.GetRoleInfo("pic")))
    local tempNum = 0
    if preHeroID then
        heroID = preHeroID
        tempNum = 200
    end
    -- 屏蔽未开放的英雄（临时处理）
    heroID = checkHeroModelId(heroID)

    if (role_liHui[3-index] == nil) then
        index = 2
    end
    local useSkinId = logicMgr.SkinManager.getHeroSkinId(heroID)
    local imageName = HeroManager.GetHeroDrawingPath(heroID,nil,useSkinId);
    resMgr:LoadModelPrefab(imageName, function(go)
        if (role_liHui[index] ~= nil) then
            destroyImmediate(role_liHui[index]);
            role_liHui[index] = nil
        end
        if drawWrapper[index] == nil then
            drawWrapper[index] = GoWrapper.New();
        end
        role_liHui[index] = newObject(go);
        role_liHui[index].name = imageName;--"role_liHui";
        Util.PlayAction(role_liHui[index], "idle1", true);
        role_liHui[index]:AddComponent(TCanvas);
        drawWrapper[index]:SetWrapTarget(role_liHui[index], true)
        DrawingParent[index]:SetNativeObject(drawWrapper[index]);
        Util.Lua_SetLocalPositionXYZ(role_liHui[index].transform, 0, 0, 0)
        local scales, pos = HeroManager.GetHeroLocationResize(heroID)
        Util.Lua_SetLocalScaleXYZ(role_liHui[index].transform, scales[1] * 0.8, scales[2] * 0.8, 1)
        Util.Lua_SetLocalPositionXYZ(role_liHui[index].transform, pos[1]-tempNum, pos[2], 1)
        role_liHui[index]:GetComponent("SkeletonGraphic").AnimationState:SetAnimation(0, "idle1", true);
        if delayObjTimer then
            utimer.remove(delayObjTimer)
            delayObjTimer = nil
        end
        if blendTimer then
            utimer.remove(blendTimer)
            blendTimer = nil
        end
        if preHeroID then
            if role_liHui[index] then
                delayObjTimer = FadeFuc(role_liHui[index],1,10,nil,function(temp)
                    Util.Lua_SetLocalPositionXYZ(role_liHui[index].transform, pos[1]+tempNum*(temp-1), pos[2],0)
                end)
            end
            if role_liHui[3-index] then
                blendTimer = FadeFuc(role_liHui[3-index],0,5,function()
                    if role_liHui[3-index] ~= nil then
                        destroyImmediate(role_liHui[3-index]);
                        role_liHui[3-index]= nil
                    end
                end,function(temp)
                    if role_liHui[3-index] then
                        local trans = role_liHui[3-index].transform
                        Util.Lua_SetLocalPositionXYZ(role_liHui[3-index].transform, trans.localPosition.x+tempNum*temp, trans.localPosition.y, trans.localPosition.z)
                    end
                end)
            end
        end
    end)
    --进入个人设置,显示默认立绘语音
    this.currentHeroId = toNumber(heroID)
    AudioManager.PlayInteractionVoice(heroID, 0, AudioManager.InteractionTagTable[2].Tag)
end

function UIHeadInfo.Setting(obj)
    showUI(PanelNames.UICommonSet)
    SetPlayerPrefs("RedUISpeed",1)
    FireEvent(Config.EventType.UpdateUISpeedRed)
end

function UIHeadInfo.onConfirmClick(obj)
    local pop = CtrlManager.GetCtrl(PanelNames.UICommonPop);
    pop.Init("12", function(b)
        if b then
            UILogin.changeAccount = true;
            --SDK退出登录
            if AppConst.isBussiness ~= 1 and not AppConst.DebugMode then
                LoginSDK.GetInstance():logOut();
            else
                this.OnChangeAccClick();
            end
        end
        return ;
    end);
end

--账号切换，断线重连
function UIHeadInfo.OnChangeAccClick()
    Game.ResetStart()
end

function UIHeadInfo.OnChangeGiftNumClick(obj)
    -- body
    showUI(PanelNames.UIChangeGiftTips);
    closeUI(PanelNames.UIHeadInfo);
end

function UIHeadInfo.OnCloseClick(obj)
    closeUI(PanelNames.UICommonSet);
    closeUI(PanelNames.UIHeadInfo);
end

function UIHeadInfo.CloseFom()
    teamController.selectedIndex = 0;
    headOpenController.selectedIndex = 0;
    this.HideChangeName()
end

function UIHeadInfo.GochangeForm()
    roleInfoHandler.SendReqModifyFomationMessage(UIHeadInfo.sendForm);
    this.CloseFom()
end

function UIHeadInfo.GoChangeHead()
    local skinId = tostring(logicMgr.HeroManager.GetRoleInfo("pic"))
    logicMgr.HeroManager.SetRoleInfo("pic", skinId)

    this.ReSetHeadIcon();
    FireEvent(Config.EventType.Refresh_Frame, { this.framePic })
    roleInfoHandler.SendReqModifyPicMessage(skinId, this.framePic);
    headOpenController.selectedIndex = 0;
end

function UIHeadInfo.OnClickSex()
    this.sexType = changeSex.selectedIndex
end

--- 名称修改
--[[function UIHeadInfo.GoChangeName()
    local money = logicMgr.ItemManager.getCurrencyCountByModelId(CurrencyEnum.GOLD)
    if logicMgr.HeroManager.GetRoleInfo("modifyCount") >= 1 and money < HelperFunc.GetGlobalNumVlue(92) then
        UISysTips.AddMsg(getLanguage("ErrorCode_3412"));
        return
    end

    local newName = inputName.text
    if #newName == 0 or newName == "" then
        UISysTips.AddMsg("名字不能为空");
        return
    end

    --请求改名
    roleInfoHandler.R_ModifyPerson(newName, this.sexType)
end]]

function UIHeadInfo.HeadBtnClick()
    this.ShowChangeHead();
    headController.selectedIndex = 1;
end

function UIHeadInfo.FrameBtnClick()
    headController.selectedIndex = 0;
    this.ShowFrame();
end

function UIHeadInfo.iSHaveFrame(itemid)
    local ishow = false;
    local hasframe = logicMgr.ItemManager.getItemDataByTabType(EnumConst.ItemTableEnum.Frame);
    if hasframe and #hasframe > 0 then
        for _, v in pairs(hasframe) do
            if v["itemModelId"] == itemid then
                ishow = true;
                break ;
            end
        end
    end
    return ishow;
end

function UIHeadInfo.ShowFrame()
    frameGet = {};
    frameUnGet = {};
    local headCfg = G.dataTable["t_headframe"]
    --for _, value in pairs(config) do
    --    if value.f_BagType == EnumConst.ItemTypeEnum.Frame then
    --        local cfg = headCfg[tostring(value["f_itemModelId"])]
    --        local data = {};
    --        data["f_itemModelId"] = value["f_itemModelId"];
    --        data["f_Icon"] = value["f_Icon"];
    --        data["isGet"] = true;
    --        if this.iSHaveFrame(value["f_itemModelId"]) and cfg["f_Hide"] == 1 then
    --            table.insert(frameGet, data);
    --        else
    --            if cfg["f_Hide"] == 1 then
    --                data["isGet"] = false;
    --                table.insert(frameUnGet, data);
    --            end
    --        end
    --    end
    --end
    for _, value in pairs(headCfg) do
        local data = {}
        data["f_itemModelId"] = value["f_ItemId"];
        data["f_Icon"] =  G.dataTable["t_item"][tostring(value["f_ItemId"])]["f_Icon"];
        --data["isGet"] = true;
        if FrameManager.IsHaveFrame(value.f_Id) and value["f_Hide"] == 1 then
            data["isGet"] = true;
            local frameLastTime = FrameManager.GetFrameLastTime(value.f_Id)
            data["endTime"] = frameLastTime
            table.insert(frameGet, data);
        else
            if value["f_Hide"] == 1 then
                data["isGet"] = false;
                table.insert(frameUnGet, data);
            end
        end
    end
    table.sort(frameGet, function(a, b)
        return a.f_itemModelId < b.f_itemModelId
    end);
    table.sort(frameUnGet, function(a, b)
        return a.f_itemModelId < b.f_itemModelId
    end);
    for k, v in pairs(frameUnGet) do
        table.insert(frameGet, v);
    end
    frameUnGet = {};
    dynamicListUp.itemRenderer = this.RenderFrames;
    dynamicListUp.numItems = #frameGet;
    --dynamicListDown.itemRenderer = this.RenderNotHaveFrams;
    --dynamicListDown.numItems = #frameUnGet;
end

function UIHeadInfo.RenderNotHaveFrams(idx, itemobj)
    local itemValue = frameUnGet[idx + 1];
    local beHave = itemobj:GetController("c1");
    beHave.selectedIndex = 1;
    itemobj:GetChild("frame").url = "ui://ICONAtlas/" .. itemValue["f_Icon"];
    itemobj:GetChild("head"):GetChild("HeadIcon").url = "ui://ICONAtlas/" .. HeroManager.GetHeroBIcon(this.headPic)
    itemobj:GetChild("frame").visible = true;
end

function UIHeadInfo.RenderFrames(idx, itemobj)
    local itemValue = frameGet[idx + 1];
    itemobj.onClick:Clear();
    local gou = itemobj:GetController("c2");
    local beHave = itemobj:GetController("c1");
    local txtTime = itemobj:GetChild("time");
    local timeLimitController = itemobj:GetController("type");
    timeLimitController.selectedIndex = 0
    gou.selectedIndex = 0;
    if itemValue["isGet"] then
        beHave.selectedIndex = 0;
        itemobj:GetChild("particle").visible = true;
        this.LoadParticle(itemValue["f_itemModelId"], itemobj);
        itemobj.onClick:Add(function()
            this.changehead(itemValue["f_Icon"], itemobj);
        end);
        local endTime = itemValue["endTime"]
        if endTime and endTime > 0 then
            local countTime = endTime - HelperFunc.GetServerTime();
            if countTime > 0 then
                timeLimitController.selectedIndex = 1;
                if UIHeadInfo.timerCountDown[idx] then
                    utimer.remove(UIHeadInfo.timerCountDown[idx]);
                    UIHeadInfo.timerCountDown[idx] = nil;
                end
                UIHeadInfo.timerCountDown[idx] =  utimer.timeCall(function()
                    countTime = countTime - 1;
                    if countTime < 0 then
                        countTime = 0;
                    end
                    txtTime.text = HelperFunc.GetTimeStr2(countTime);
                end, 1000, -1);
            end
        end


    else
        itemobj:GetChild("particle").visible = false;
        beHave.selectedIndex = 1;
    end
    itemobj:GetChild("frame").visible = true;
    itemobj:GetChild("head"):GetChild("HeadIcon").url = "ui://ICONAtlas/" .. HeroManager.GetHeroBIcon(this.headPic)
    itemobj:GetChild("frame").url = "ui://ICONAtlas/" .. itemValue["f_Icon"];
    if (tonumber(this.framePic) == tonumber(itemValue["f_Icon"])) then
        --gou:SetActive(true);
        gou.selectedIndex = 1;
        --beHave.selectedIndex = 1;
        LiHuiObj = itemobj;
        this.updateHeadFramesDec(itemValue["f_itemModelId"])
    end
    itemobj.onClick:Add(function()
        this.updateHeadFramesDec(itemValue["f_itemModelId"]);
    end);
end

function UIHeadInfo.updateHeadFramesDec(itemid)
    ChoseHeadDesc.text = ItemManager.GetItemDesc(itemid);
    barName.text = logicMgr.ItemManager.GetItemName(itemid);
    local config = G.dataTable["t_headframe"][tostring(itemid)]
    local tb = config.f_CharacterValue

    if string.IsEmpty(config.f_CharacterValue) then
        tb = {}
    end

    if #tb == 0 then
        playerHead_attr.selectedIndex = 0
    elseif #tb == 3 then
        playerHead_attr.selectedIndex = 1
    elseif #tb == 4 then
        playerHead_attr.selectedIndex = 2
    end
    local at = nil
    for k,v in pairs(tb) do
        at = G.dataTable["t_attributelibrary"][tostring(v[1])]
        if at then
            if at.f_AttributeType == 2 then
                attr_list[k]:GetChild("number").text = table.concat({at.f_AttributeName, " +", v[2] / 100 , "%"})
            else
                attr_list[k]:GetChild("number").text = table.concat({at.f_AttributeName, " +", v[2]})
            end
            attr_list[k]:GetChild("image").url = EnumConst.AtlasPath.ICONAtlas.."attr" .. v[1];
        end
    end
end
function UIHeadInfo.LoadParticle(itemid, itemobj, top, pre)
    local frameID = decodeJsonStrToTabel(config[tostring(itemid)]["f_ItemFunction"])
    if top then
        if particles[topid] ~= nil then
            destroyImmediate(particles[topid]);
            particles[topid] = nil;
        end
        itemid = itemid * 10;
        topid = itemid;
    end
    if pre then
        if particles[preid] ~= nil then
            destroyImmediate(particles[preid]);
            particles[preid] = nil;
        end
        itemid = itemid * 100
        preid = itemid;
    end
    if frameID[2] ~= 0 then
        resMgr:LoadModelPrefab("Fx/EFF_Frame_" .. frameID[2], function(go)
            if (UIHeadInfo.particles[itemid] ~= nil) then
                destroyImmediate(UIHeadInfo.particles[itemid]);
                UIHeadInfo.particles[itemid] = nil
            end
            local drawWrapper = UIHeadInfo.drawWrappers[itemid];
            if (drawWrapper == nil) then
                drawWrapper = GoWrapper.New();
                UIHeadInfo.drawWrappers[itemid] = drawWrapper
            end
            UIHeadInfo.particles[itemid] = newObject(go);
            UIHeadInfo.particles[itemid] .name = tostring(frameID[2]);
            UIHeadInfo.particles[itemid]:AddComponent(TCanvas);
            drawWrapper:SetWrapTarget(UIHeadInfo.particles[itemid], false)
            local particle = itemobj:GetChild("particle");
            particle.visible = true;
            particle:SetNativeObject(drawWrapper);
            Util.Lua_SetLocalPositionXYZ(UIHeadInfo.particles[itemid] .transform, 50, -50, 0)
            Util.Lua_SetLocalScaleXYZ(UIHeadInfo.particles[itemid] .transform, 1.2, 1.2, 0)
        end)
    end
end

function UIHeadInfo.AskHeadFrameInfo()
    picFrameHandler.ReqSendFrameInfo()
end

function UIHeadInfo.UpdateHeadFrameInfo()
    this.ShowChangeHead();
    --printError("========UIHeadInfo.UpdateHeadFrameInfo========")
    dynamicListUp.numItems = #frameGet;
end

function UIHeadInfo.RefreshCenterRed()
    bt_SetBtn:GetChild("UIRedDots"):GetController("c1").selectedIndex = logicMgr.SDKManager.GetAccountCenterCount() > 0 and 2 or 0
end

function UIHeadInfo.ShowChangeHead()
    RedDotsHeadFrameHandler.showRed = false
    RedDotsHeadFrameHandler.update()
    headOpenController.selectedIndex = 1;
    if this.headPic == nil then
        this.headPic = logicMgr.HeroManager.GetRoleInfo("pic")
    end
    --if this.framePic == nil then
    --    this.framePic = logicMgr.HeroManager.GetRoleInfo("picFrame");
    --end
    this.framePic = logicMgr.HeroManager.GetRoleInfo("picFrame");
    if (headIcon == nil) then
        headIcon.url = "ui://ICONAtlas/" .. logicMgr.HeroManager.GetHeroBIcon(this.headPic);
    end
    headFrame.url = "ui://ICONAtlas/" .. this.framePic;
    barName.text = logicMgr.ItemManager.GetItemName(this.framePic);
    this.LoadParticle(this.framePic, ChoseHeadIconPanel:GetChild("HeadIcon"), nil, true);
    this.ShowFrame();
    --local HeroList = G.dataTable["t_hero"];
    --listBeGetTab = {};
    --listUnGetTab = {};

    --local myHeroList = logicMgr.HeroManager.getOwnerHeroList(true);
    --local havehero = {};
    --for i = 1, #myHeroList do
    --    local itemValue = {}
    --    itemValue["partnerModelId"] = myHeroList[i].partnerModelId
    --    itemValue["round"] = 1;
    --    havehero[tostring(myHeroList[i].partnerModelId)] = 1;
    --    table.insert(listBeGetTab, itemValue);
    --end
    --
    --for k, v in pairs(HeroList) do
    --    if (v.f_HeroID < 200) then
    --        if (havehero[tostring(v.f_HeroID)] == nil) then
    --            local itemValue = {}
    --            itemValue["partnerModelId"] = v.f_HeroID
    --            itemValue["round"] = 1;
    --            itemValue["nothave"] = 1;
    --            table.insert(listUnGetTab, itemValue);
    --        end
    --    end
    --end
    --headController.selectedIndex = 1;
    --dynamicListUp.itemRenderer = this.RenderHeads;
    --dynamicListUp.numItems = #listBeGetTab;
    --dynamicListDown.itemRenderer = this.RenderNotHaveHeads;
    --dynamicListDown.numItems = #listUnGetTab
end

--function UIHeadInfo.RenderHeads(idx, itemobj)
--    local itemValue = listBeGetTab[idx + 1];
--    --local HeadRectDrawItem = CtrlManager.GetCtrl(PanelNames.HeadRectDrawItem);
--    --itemobj:GetChild("head"):GetChild("particle").visible = false;
--    itemobj:GetChild("frame").visible = false;
--    itemobj:GetChild("particle").visible = false;
--    itemobj:GetChild("head").visible = true;
--    if HeadRectDrawItem ~= nil then
--        --HeadRectDrawItem.initData(itemobj, itemValue, LuaBehaviour);
--        itemobj.onClick:Clear();
--        local gou = itemobj:GetController("c2");
--        local beHave = itemobj:GetChild("head"):GetController("c1");
--        beHave.selectedIndex = 0;
--        gou.selectedIndex = 0;
--        itemobj:GetChild("head"):GetChild("HeadIcon").url = "ui://ICONAtlas/" .. logicMgr.HeroManager.GetHeroConfigbyModelId(itemValue["partnerModelId"]).f_HeroIcon
--        --gou:SetActive(false);
--        if (tostring(this.headPic) == tostring(itemValue["partnerModelId"])) then
--            --gou:SetActive(true);
--            gou.selectedIndex = 1;
--            --beHave.selectedIndex = 1;
--            LiHuiObj = itemobj;
--        end
--        if (itemValue["nothave"] == nil) then
--            itemobj.onClick:Add(function()
--                this.changehead(itemValue["partnerModelId"], itemobj);
--            end);
--        end
--    end
--end

--function UIHeadInfo.RenderNotHaveHeads(idx, itemobj)
--    local itemValue = listUnGetTab[idx + 1];
--    itemobj:GetChild("frame").visible = false;
--    itemobj:GetChild("head").visible = true;
--    local beHave = itemobj:GetChild("head"):GetController("c1");
--    beHave.selectedIndex = 1;
--    itemobj:GetChild("head"):GetChild("HeadIcon").url = "ui://ICONAtlas/" .. logicMgr.HeroManager.GetHeroConfigbyModelId(itemValue["partnerModelId"]).f_HeroIcon;
--
--end

function UIHeadInfo.ShowSideManChose()
    --PicIDNotSave = logicMgr.HeroManager.roleInfo.background;
    --this.ShowSelectFom(2);
    showUI(PanelNames.UISelectShow)
end

--- 看板娘界面
function UIHeadInfo.ShowSide2DChose()
    if not FuncOpenManager.isOpen(Config.FuncOpenType.Side2D, true, btnChoseSide2D) then
        return
    end
    showUI(PanelNames.UISide2D)
end

function UIHeadInfo.ShowSelectFom(isChoseSide)
    teamController.selectedIndex = 1;
    UIHeadInfo.RefreshPage(isChoseSide);
end

function UIHeadInfo.OnTabChanged()
    UIHeadInfo.RefreshFormationList()
end

function UIHeadInfo.RefreshFormationList()
    local index = ctrlTabController.selectedIndex
    local herotb = logicMgr.HeroManager.getOwnerHeroList(nil,nil,true);
    table_banch = {};
    for i = 1, #herotb do

        local temphero = herotb[i];
        local schoolLimit = (temphero.type == index)
        if index == EnumConst.HeroTypeEnum.HeroTypeAll then
            schoolLimit = true
        end
        if schoolLimit then
            local itemValue = {};
            itemValue["partnerModelId"] = temphero.partnerModelId
            itemValue["partnerId"] = temphero.partnerId
            itemValue["hide"] = 1;
            itemValue["star"] = temphero.star;
            itemValue["type"] = temphero.type;
            itemValue["icon"] = temphero.icon;
            itemValue["level"] = temphero.level;
            itemValue["quality"] = temphero.quality;
            if (isChoseSide == 2) then
                itemValue["Side"] = 1;
            end
            table.insert(table_banch, itemValue);
        end
    end
    table.sort(table_banch, logicMgr.HeroManager.sortHero);
    logicMgr.HeroManager.SetMyHeroSkin(table_banch)
    dynamicListForm.itemRenderer = this.SetDataForm;
    dynamicListForm.numItems = #table_banch;
end

function UIHeadInfo.RefreshPage(isChoseSide)
    UIHeadInfo.RefreshSendForm();
    UIHeadInfo.AddFormHero();
    UIHeadInfo.RefreshFormationList()
end

function UIHeadInfo.SetDataForm(idx, itemobj)
    local itemValue = table_banch[idx + 1];
    local HeadRectDrawItem = CtrlManager.GetCtrl(PanelNames.HeadRectItem);
    if HeadRectDrawItem ~= nil then
        HeadRectDrawItem.initData(itemobj, itemValue);

        itemobj.onClick:Clear();
        local gou = itemobj:GetController("ctrlHadBattle");
        gou.selectedIndex = 0;
        --gou:SetActive(false);
        if (itemValue["Side"] == nil) then
            for i = 1, 5 do
                if (UIHeadInfo.sendForm[i] == itemValue["partnerId"]) then
                    this.showHeroObj[i] = itemobj;
                    gou.selectedIndex = 1;
                    break ;
                end
            end
            itemobj.onClick:Add(function()
                this.JoinInFom(itemValue["partnerId"], itemobj);
            end);
        else
            if (PicIDNotSave == tonumber(itemValue["partnerModelId"])) then
                gou.selectedIndex = 1;
                LiHuiObj = itemobj;
            end
            itemobj.onClick:Add(itemobj, function()
                this.changePic(itemValue["partnerModelId"], itemobj);
            end);
        end
    end
end

function UIHeadInfo.AddFormHero()
    for i = 1, #headFormationObj do
        if i <= 5 then
            local headRectItem = headFormationObj[i];
            local controller = headRectItem:GetController("state");
            if controller then 
                controller.selectedIndex = 0;
                local temphero = logicMgr.HeroManager.getHeroDatabyPartnerId(UIHeadInfo.sendForm[i]);
                logicMgr.HeroManager.SetMyOneHeroSkin(temphero)
                local ctrlItem = CtrlManager.GetCtrl(PanelNames.HeadRectBItem);
                if (temphero ~= nil and ctrlItem) then
                    controller.selectedIndex = 1;
                    temphero.notShowNum = true;
                    ctrlItem.initData(headRectItem:GetChild("hero"), temphero);
                    headRectItem.onClick:Clear();
                    headRectItem.onClick:Add(function()
                        this.JoinInFom(UIHeadInfo.sendForm[i], this.showHeroObj[i]);
                    end);
                end
            end
        else
            break ;
        end
    end
end

function UIHeadInfo.cancelInFom(index)
    this.JoinInFom(UIHeadInfo.sendForm[index], this.showHeroObj[index]);
end

function UIHeadInfo.JoinInFom(sendID, Obj)
    for i = 1, 5 do
        if (UIHeadInfo.sendForm[i] == sendID) then
            UIHeadInfo.sendForm[i] = "0";
            Obj:GetController("ctrlHadBattle").selectedIndex = 0;
            this.AddFormHero();
            return ;
        end
    end
    for i = 1, 5 do
        if (UIHeadInfo.sendForm[i] == "0") then
            UIHeadInfo.sendForm[i] = sendID;
            this.showHeroObj[i] = Obj;
            --Obj.transform:Find("gou").gameObject:SetActive(true);
            Obj:GetController("ctrlHadBattle").selectedIndex = 1;
            this.AddFormHero();
            return ;
        end
    end
    UISysTips.AddMsg(getLanguage("Sys_MsgTeamShowFull"));
end

function UIHeadInfo.changehead(sendID, Obj)
    if (tostring(sendID) ~= this.headPic) or tostring(sendID) ~= this.framePic then
        local gouController = Obj:GetController("c2");
        if (LiHuiObj ~= nil) then
            LiHuiObj:GetController("c2").selectedIndex = 0;
        end
        LiHuiObj = Obj;
        gouController.selectedIndex = 1;
        if headController.selectedIndex == 1 then
            this.headPic = tostring(sendID);
            local image = G.dataTable["t_hero"][this.headPic].f_HeroIcon;
            headIcon.url = "ui://ICONAtlas/" .. image;
        else
            this.framePic = tostring(sendID);
            headFrame.url = "ui://ICONAtlas/" .. this.framePic;
            this.LoadParticle(this.framePic, ChoseHeadIconPanel:GetChild("HeadIcon"), nil, true);
        end
    end
end
function UIHeadInfo.changePic(sendID, Obj)
    if (tonumber(sendID) ~= PicIDNotSave) then
        PicIDNotSave = sendID;
        if (LiHuiObj ~= nil) then
            --LiHuiObj.transform:Find("gou").gameObject:SetActive(false);
            local gouController = LiHuiObj:GetController("c2");
            gouController.selectedIndex = 0;

        end
        LiHuiObj = Obj;
        local gouController = LiHuiObj:GetChild("head"):GetController("c2");
        gouController.selectedIndex = 1;
        --LiHuiObj.transform:Find("gou").gameObject:SetActive(true);
    end
end

function UIHeadInfo.ResetFormation()
    this.ReSetHeadIcon();
    for i = 1, 5 do
        local indexFormObj = heroFormObj[i];
        local controller = indexFormObj:GetController("state");
        controller.selectedIndex = 0;
        if (UIHeadInfo.sendForm[i] ~= "0") then
            local pData = logicMgr.HeroManager.getHeroDatabyPartnerId(UIHeadInfo.sendForm[i]);
            logicMgr.HeroManager.SetMyOneHeroSkin(pData)
            local ctrlItem = CtrlManager.GetCtrl(PanelNames.HeadRectBItem);
            if (pData ~= nil and ctrlItem) then
                controller.selectedIndex = 1;
                pData.notShowNum = true;
                ctrlItem.initData(indexFormObj:GetChild("hero"), pData);
            end
        end
    end
end

function UIHeadInfo.SetInfo()
    setController.selectedIndex = 0;
    this.RefreshSendForm();
    this.ResetFormation();
    this.AddFormHero();
    this.ShowDrawing();
    local roleInfo = G.serverData["roleInfo"];
    local level = logicMgr.HeroManager.GetRoleLevel()

    --local myHero = logicMgr.HeroManager.getMyself();
    if roleInfo ~= nil then
        local att = roleInfo.show;
        ctrlMainSex.selectedIndex = logicMgr.HeroManager.GetRoleInfo("sex")
        lable_name.text = logicMgr.HeroManager.GetRoleName()
        lable_Lv.text = string.format(getLanguage("Level"), logicMgr.HeroManager.GetRoleLevel())
        lable_Id.text = att.playerId;
        local curExp = logicMgr.ItemManager.getCurrencyCountByModelId(CurrencyEnum.RoleExp);
        local maxExp = dataTable.getRow("t_characterexp", MakeTopLevelId(logicMgr.HeroManager.GetRoleLevel())).f_CharacterExp
        guildNameText.text = logicMgr.GuildManager.getUnionName();
        guildPostText.text = logicMgr.GuildManager.getMyUnionTitle();

        this.numLevelNow.text = curExp;
        this.numLevelNeed.text = maxExp;
        local value = curExp / maxExp
        if value >= 1 then
            value = 1;
        end
        exp.value = value * 100
        --power.text = getNumString(dataTable.getRow("t_characterexp", level).f_CharacterExp);
        power.text = HelperFunc.FormatResourceNum(logicMgr.HeroManager.GetHerosSumPower(), true)
        headIcon.url = logicMgr.HeroManager.GetRoleIcon();
        --framepre.url = "ui://ICONAtlas/"..this.framePic;
        local tempMapID = logicMgr.MapManager.getMapId()
        if (tempMapID == nil) then
            mainMap.text = "1-1";
        else
            local tempMap = G.dataTable["t_stage"][tostring(tempMapID)];
            mainMap.text = tempMap.f_ChapterId .. "-" .. tempMap.f_StageNum
        end
        local tempTower = logicMgr.TowerManager.returnTowerInfo(1)
        if (tempTower == nil) then
            mysticalRoad.text = "0"
        else
            mysticalRoad.text = tostring(tempTower.layerId - 1);
        end

        this.GetArenaRank(logicMgr.ArenaManager.getBaseInfo());

        local tabOwner, tabUnOwner = logicMgr.HeroManager.GetAllHero(true,true);
        HeroGot.text = tostring(#tabOwner);
        local allHero = #tabOwner + #tabUnOwner;
        HeroGotMax.text = allHero;
        HeroGotRate.text = "(" .. math.floor((#tabOwner / allHero) * 100) .. "%" .. ")";
    end
    local severData = logicMgr.LoginManager.GetServerInAll(AppConst.ServerId) --logicMgr.LoginManager.GetLoginRecordIPInfo();
    if severData ~= nil then
        Severname.text = severData[Server_ENU_INDEX.NAME];
    end
    local pro = logicMgr.LBSManager.GetLocationName();
    if pro == nil or #pro == 0 then
        this.province.text = getLanguage("Sys_LbsUnableLocate");
    else
        this.province.text = pro;
    end

    this.city.text = "";
end

function UIHeadInfo.RefreshSendForm()
    local roleFormation = {};

    local formations = G.serverData["roleInfo"].show.formation;
    local str = ""
    for i = 1, #formations do
        str = str..","..tostring(formations[i])
        local heroItem = HeroManager.getHeroDatabyPartnerId(formations[i]);
        table.insert(roleFormation, heroItem);
    end
    log("UIHeadInfo.SetInfo "..str)
    if (#roleFormation == 0) then
        UIHeadInfo.sendForm = { "0", "0", "0", "0", "0" };
        local herotab = logicMgr.HeroManager.getOwnerHeroList(true,nil,true);
        for i = 1, #herotab do
            local indexhero = herotab[i]
            if (i <= 5) then
                UIHeadInfo.sendForm[i] = indexhero.partnerId
            else
                break ;
            end
        end
        this.GochangeForm();
    else
        UIHeadInfo.sendForm = { "0", "0", "0", "0", "0" };
        for i = 1, #roleFormation do
            if i <= 5 then
                local indexherodata = roleFormation[i]
                if (indexherodata ~= nil) then
                    UIHeadInfo.sendForm[i] = logicMgr.HeroManager.getHeroDatabyModelId(indexherodata.partnerModelId, true).partnerId
                end
            end
        end
    end
end

function UIHeadInfo.TitleRedListen()
    if not logicMgr.GuideMgr.IsGuiding() then
        local guildId = logicMgr.GuideMgr.GetGuideID();
        if guildId == nil or tonumber(guildId) ~= 3002 then
            UIRedDots.addViewListen(PanelNames.UIHeadInfo, "UIHeadInfo" .. titleBtn .name, titleBtn, Config.RedDotsType.Title);
        end
    end
end

function UIHeadInfo.GetArenaRank(base)
    local rank = Util.GetPlayerPrefs(logicMgr.HeroManager.GetRoleInfo().playerId .. "_ArenaRank");
    if rank == nil or tonumber(rank) == -1 then
        AreanaRankNow.text = "未上榜";
        AreanaRankMax.text = "未上榜";
        return ;
    end
    if base == nil then
        AreanaRankNow.text = "未上榜";
        return ;
    end
    local tempRank = base["rank"]
    if (tempRank == -1) then
        AreanaRankNow.text = "未上榜";
    else
        AreanaRankNow.text = tostring(tempRank);
    end
    AreanaRankMax.text = tostring(tonumber(rank));
end

function UIHeadInfo.onCopyClick()
    UnityEngine.GUIUtility.systemCopyBuffer = lable_Id.text
    UISysTips.AddMsg(getLanguage("CopySuccess"))
end

function UIHeadInfo.onExhangeClick()
    UISysTips.AddMsg("暂未开放")
end
return UIHeadInfo;